//
//  TTAppDelegate.m
//  Tint
//
//  Created by Kevin Wu on 2/22/12.
//  Copyright (c) 2012 Telligenty. All rights reserved.
//

#import "TTAppDelegate.h"
#import "TTBasicCommon.h"

@implementation TTAppDelegate


#pragma mark - Accessors

@synthesize window = _window;



#pragma mark - Memory

- (void)dealloc
{
    TTRelease(_window);
    [super dealloc];
}



#pragma mark - Public

+ (id)sharedObject
{
    return [UIApplication sharedApplication].delegate;
}


- (UIWindow *)newWindow
{
    UIWindow *window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
    window.backgroundColor = [UIColor whiteColor];
    return window;
}

- (UIViewController *)newViewController
{
    return nil;
}



- (void)willCreateWindow
{
}

- (void)didCreateWindow
{
}



- (BOOL)shouldShowStatusBar
{
    return YES;
}

- (UIStatusBarStyle)statusBarStyle
{
    return UIStatusBarStyleDefault;
}



#pragma mark - UIApplicationDelegate

/*
 * Override this function, call super, and code like this:
 * 
 * [super application:application didFinishLaunchingWithOptions:launchOptions];
 * 
 * [self willCreateWindow];
 * 
 * UIWindow *wnd = [self newWindow];
 * self.window = wnd;
 * [wnd release];
 * 
 * UIViewController *vc = [self newViewController];
 * self.window.rootViewController = vc;
 * [vc release];
 * 
 * [self.window makeKeyAndVisible];
 * 
 * [self didCreateWindow];
 * 
 */
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    
    
    ////////////////////////////////////////////////////////////////////////////
    // Launch times
    TTIncreaseLaunchTimes();
    ////////////////////////////////////////////////////////////////////////////
    
    
    ////////////////////////////////////////////////////////////////////////////
    // Status bar
    if ( [self shouldShowStatusBar] ) {
        [[UIApplication sharedApplication] setStatusBarHidden:NO withAnimation:UIStatusBarAnimationNone];
        [[UIApplication sharedApplication] setStatusBarStyle:[self statusBarStyle] animated:NO];
    } else {
        [[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationNone];
    }
    ////////////////////////////////////////////////////////////////////////////
    
    return YES;
}

@end
